package com.cskaoyan.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author stone
 * @date 2022/01/03 10:24
 */
@RestController
@RequestMapping("upload")
public class UploadController {

    @Value("${file.path}")
    String path;
//        String path = "D:\\tmp\\";
    @RequestMapping("file")
    public String uploadFile(MultipartFile file) throws IOException {
        file.transferTo(new File(path,file.getOriginalFilename()));

        return "OK";
    }
}
